package cn.leedsoft.luma.plugins.ehcache;

import cn.leedsoft.luma.mapper.domain.User;
import cn.leedsoft.luma.mapper.domain.UserExample;
import cn.leedsoft.luma.mapper.generate.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * Created by leeds on 2016/6/22 10:49.
 */
@Component
public class UserEhcache {
    @Autowired
    private UserMapper userMapper;

    @Cacheable("ehcache.user.list")//todo 是否可以把cache的name，用常量，统一定义在一处。
    public List<User> getUserList(Long id) {
        UserExample userExample = new UserExample();
        userExample.createCriteria().andIdEqualTo(id);
        return userMapper.selectByExample(userExample);
    }
}
